#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
typedef long long LL;
const LL INF=1000000000000000LL;
const int maxn=100010;
vector<LL>v;
LL s[maxn],a[maxn],c[maxn],K;
inline int lowbit(int x){return x&(x^(x-1));}
void add(int x,int t,int n){while(x<=n+5){c[x]+=t;x+=lowbit(x);}} 
LL query(int x){LL sum=0;while(x>0){sum+=c[x];x-=lowbit(x);}return sum;}
bool check(int n,LL key,LL k){
	for(int i=1;i<=n+5;i++)c[i]=0;
	add(lower_bound(v.begin(),v.end(),0)-v.begin()+1,1,n);
	for(int i=1;i<=n;i++){
		k-=query(upper_bound(v.begin(),v.end(),s[i]-key)-v.begin());
		add(lower_bound(v.begin(),v.end(),s[i])-v.begin()+1,1,n);
		if(k<=0)return true;
		}
	return false;
	}
int main(){
	int n,x;
	while(scanf("%d%I64d",&n,&K)!=EOF){
		s[0]=0;v.clear();
		for(int i=1;i<=n;i++)scanf("%d",&x),s[i]=s[i-1]+x;
		for(int i=0;i<=n;i++)v.push_back(s[i]);
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
		LL l=-INF,r=INF,mid,ans;
		while(l<=r){
			mid=(l+r)>>1;
			if(check(n,mid,K))l=mid+1,ans=mid;
			else r=mid-1;
			}
		cout<<ans<<endl;
		}
    return 0;
    }
